package com.chonry.web2.algorithm;

import io.shardingjdbc.core.api.algorithm.sharding.PreciseShardingValue;
import io.shardingjdbc.core.api.algorithm.sharding.standard.PreciseShardingAlgorithm;
import java.util.Collection;
import java.util.Iterator;

public class ShardingDbAlgorithm implements PreciseShardingAlgorithm<Integer> {
    public ShardingDbAlgorithm() {
    }

    public String doSharding(Collection<String> availableTargetNames, PreciseShardingValue<Integer> shardingValue) {
        String dbBaseSufix = String.valueOf((Integer)shardingValue.getValue() % availableTargetNames.size() + 1);
        Iterator var4 = availableTargetNames.iterator();

        String db;
        do {
            if (!var4.hasNext()) {
                throw new UnsupportedOperationException();
            }

            db = (String)var4.next();
        } while(!db.endsWith(dbBaseSufix));

        return db;
    }
}
